"""
文件名: AddressInterface
"""
from interface.member import MemberInterface
from utils.send_method import SendMethod


class AddressInterface:
    def __init__(self, headers):
        self.url = "http://47.108.206.100:8085"
        self.headers = headers

    def address_add(self, body):
        """添加收货地址"""
        method = 'post'
        url = self.url + '/member/address/add'
        return SendMethod.send_method(method=method, url=url, json=body, headers=self.headers)

    def get_address(self):
        """查看收货地址"""
        method = 'get'
        url = self.url + '/member/address/list'
        return SendMethod.send_method(method=method, url=url, headers=self.headers)


if __name__ == '__main__':
    url = "http://47.108.206.100:8085"
    body = {
        "username": "jack",
        "password": "123456"
    }
    headers = MemberInterface().get_token(body)
    address = AddressInterface(headers)
    payload = {
        "city": "成都市",
        "defaultStatus": 0,
        "detailAddress": "天府大道388号",
        "id": 0,
        "memberId": 0,
        "name": "jack",
        "phoneNumber": "13800138000",
        "postCode": "222222",
        "province": "四川省",
        "region": "武侯区"
    }
    print(address.address_add(payload))
